package com.ruoyi.project.charge.service.impl;

import com.ruoyi.project.charge.mapper.DrugMapper;
import com.ruoyi.project.charge.service.DrugService;
import com.ruoyi.project.charge.vo.DispatchParams;
import com.ruoyi.project.charge.vo.RefundParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @auther:YU JIANG
 * @date:2021/7/15
 * @time:18:12
 */
@Service
public class DrugServiceImpl implements DrugService {

    @Autowired
    private DrugMapper drugMapper;

    @Override
    public int updateStock(DispatchParams params) {
        List<String> drug_id = params.getDrug_id();
        List<String> medical_num = params.getMedical_num();
        int j = 1;
        for (int i = 0; i < drug_id.size() || i < medical_num.size(); i++) {
            try {
                drugMapper.updateStock(medical_num.get(i), drug_id.get(i));
            } catch (Exception e) {
                e.printStackTrace();
                j = 0;
            }
        }
        return j;
    }
}
